package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DeclarationGRReport;
import com.ruoyi.system.service.IDeclarationGRReportService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 个人报表Controller
 * 
 * @author triangle
 * @date 2022-08-13
 */
@Controller
@RequestMapping("/system/declarationGRReport")
public class DeclarationGRReportController extends BaseController
{
    private String prefix = "system/declarationGRReport";

    @Autowired
    private IDeclarationGRReportService declarationGRReportService;

    @RequiresPermissions("system:declarationGRReport:view")
    @GetMapping()
    public String declarationGRReport()
    {
        return prefix + "/declarationGRReport";
    }

    /**
     * 查询个人报表列表
     */
    @RequiresPermissions("system:declarationGRReport:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DeclarationGRReport declarationGRReport)
    {
        startPage();
        List<DeclarationGRReport> list = declarationGRReportService.selectDeclarationGRReportList(declarationGRReport);
        return getDataTable(list);
    }

    /**
     * 导出个人报表列表
     */
    @RequiresPermissions("system:declarationGRReport:export")
    @Log(title = "个人报表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DeclarationGRReport declarationGRReport)
    {
        List<DeclarationGRReport> list = declarationGRReportService.selectDeclarationGRReportList(declarationGRReport);
        ExcelUtil<DeclarationGRReport> util = new ExcelUtil<DeclarationGRReport>(DeclarationGRReport.class);
        return util.exportExcel(list, "个人报表数据");
    }

    /**
     * 新增个人报表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存个人报表
     */
    @RequiresPermissions("system:declarationGRReport:add")
    @Log(title = "个人报表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DeclarationGRReport declarationGRReport)
    {
        return toAjax(declarationGRReportService.insertDeclarationGRReport(declarationGRReport));
    }

    /**
     * 修改个人报表
     */
    @RequiresPermissions("system:declarationGRReport:edit")
    @GetMapping("/edit/{decId}")
    public String edit(@PathVariable("decId") Long decId, ModelMap mmap)
    {
        DeclarationGRReport declarationGRReport = declarationGRReportService.selectDeclarationGRReportByDecId(decId);
        mmap.put("declarationGRReport", declarationGRReport);
        return prefix + "/edit";
    }

    /**
     * 修改保存个人报表
     */
    @RequiresPermissions("system:declarationGRReport:edit")
    @Log(title = "个人报表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DeclarationGRReport declarationGRReport)
    {
        return toAjax(declarationGRReportService.updateDeclarationGRReport(declarationGRReport));
    }

    /**
     * 删除个人报表
     */
    @RequiresPermissions("system:declarationGRReport:remove")
    @Log(title = "个人报表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(declarationGRReportService.deleteDeclarationGRReportByDecIds(ids));
    }
}
